/*
 *
 * Copyright 2021-2025 Software Radio Systems Limited
 *
 * This file is part of srsRAN.
 *
 * srsRAN is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * srsRAN is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * A copy of the GNU Affero General Public License can be found in
 * the LICENSE file in the top-level directory of this distribution
 * and at http://www.gnu.org/licenses/.
 *
 */

#include "srsran/asn1/rrc_nr/rrc_nr.h"
#include "srsran/support/test_utils.h"
#include <cstdio>
#include <gtest/gtest.h>

using namespace asn1;
using namespace asn1::rrc_nr;

#define JSON_OUTPUT 0

class asn1_rrc_nr_test : public ::testing::Test
{
protected:
  asn1_rrc_nr_test()
  {
    srslog::fetch_basic_logger("ASN1").set_level(srslog::basic_levels::debug);
    srslog::fetch_basic_logger("ASN1").set_hex_dump_max_size(-1);

    srslog::fetch_basic_logger("RRC").set_level(srslog::basic_levels::debug);
    srslog::fetch_basic_logger("RRC").set_hex_dump_max_size(-1);

    test_logger.set_level(srslog::basic_levels::debug);
    test_logger.set_hex_dump_max_size(-1);

    // Start the log backend.
    srslog::init();
  }

  ~asn1_rrc_nr_test()
  {
    // flush logger after each test
    srslog::flush();
  }

  srslog::basic_logger& test_logger = srslog::fetch_basic_logger("TEST");
};

TEST_F(asn1_rrc_nr_test, when_eutra_nr_capabilities_correct_then_packing_successful)
{
  struct ue_mrdc_cap_s mrdc_cap;
  band_combination_s   band_combination;
  struct band_params_c band_param_eutra;
  band_param_eutra.set_eutra();
  band_param_eutra.eutra().ca_bw_class_dl_eutra_present = true;
  band_param_eutra.eutra().ca_bw_class_ul_eutra_present = true;
  band_param_eutra.eutra().band_eutra                   = 1;
  band_param_eutra.eutra().ca_bw_class_dl_eutra         = asn1::rrc_nr::ca_bw_class_eutra_opts::options::a;
  band_param_eutra.eutra().ca_bw_class_ul_eutra         = asn1::rrc_nr::ca_bw_class_eutra_opts::options::a;
  band_combination.band_list.push_back(band_param_eutra);
  struct band_params_c band_param_nr;
  band_param_nr.set_nr();
  band_param_nr.nr().ca_bw_class_dl_nr_present = true;
  band_param_nr.nr().ca_bw_class_ul_nr_present = true;
  band_param_nr.nr().band_nr                   = 78;
  band_param_nr.nr().ca_bw_class_dl_nr         = asn1::rrc_nr::ca_bw_class_nr_opts::options::a;
  band_param_nr.nr().ca_bw_class_ul_nr         = asn1::rrc_nr::ca_bw_class_nr_opts::options::a;
  band_combination.band_list.push_back(band_param_nr);

  mrdc_cap.rf_params_mrdc.supported_band_combination_list.push_back(band_combination);

  mrdc_cap.rf_params_mrdc.ext = true;

  // RF Params MRDC applied_freq_band_list_filt
  freq_band_info_c band_info_eutra;
  band_info_eutra.set_band_info_eutra();
  band_info_eutra.band_info_eutra().ca_bw_class_dl_eutra_present = false;
  band_info_eutra.band_info_eutra().ca_bw_class_ul_eutra_present = false;
  band_info_eutra.band_info_eutra().band_eutra                   = 1;
  mrdc_cap.rf_params_mrdc.applied_freq_band_list_filt.push_back(band_info_eutra);

  freq_band_info_c band_info_nr;
  band_info_nr.set_band_info_nr();
  band_info_nr.band_info_nr().band_nr = 78;
  mrdc_cap.rf_params_mrdc.applied_freq_band_list_filt.push_back(band_info_nr);

  // rf_params_mrdc supported band combination list v1540

  band_combination_list_v1540_l* band_combination_list_v1450 = new band_combination_list_v1540_l();
  band_combination_v1540_s       band_combination_v1540;

  band_params_v1540_s band_params_a;
  band_params_a.srs_tx_switch_present      = true;
  band_params_a.srs_carrier_switch_present = false;
  band_params_a.srs_tx_switch.supported_srs_tx_port_switch =
      band_params_v1540_s::srs_tx_switch_s_::supported_srs_tx_port_switch_opts::not_supported;
  band_combination_v1540.band_list_v1540.push_back(band_params_a);

  band_params_v1540_s band_params_b;
  band_params_b.srs_tx_switch_present = true;
  band_params_b.srs_tx_switch.supported_srs_tx_port_switch =
      band_params_v1540_s::srs_tx_switch_s_::supported_srs_tx_port_switch_opts::t1r2;
  band_params_b.srs_carrier_switch_present = false;
  band_combination_v1540.band_list_v1540.push_back(band_params_b);

  // clang-format off
  band_combination_v1540.ca_params_nr_v1540_present = false;
  band_combination_v1540.ca_params_nr_v1540.simul_csi_reports_all_cc_present = true;
  band_combination_v1540.ca_params_nr_v1540.csi_rs_im_reception_for_feedback_per_band_comb.max_num_simul_nzp_csi_rs_act_bwp_all_cc_present = true;
  band_combination_v1540.ca_params_nr_v1540.csi_rs_im_reception_for_feedback_per_band_comb.max_num_simul_nzp_csi_rs_act_bwp_all_cc = 5;
  band_combination_v1540.ca_params_nr_v1540.csi_rs_im_reception_for_feedback_per_band_comb.total_num_ports_simul_nzp_csi_rs_act_bwp_all_cc_present = true;
  band_combination_v1540.ca_params_nr_v1540.csi_rs_im_reception_for_feedback_per_band_comb.total_num_ports_simul_nzp_csi_rs_act_bwp_all_cc = 32;
  // clang-format on
  band_combination_list_v1450->push_back(band_combination_v1540);
  mrdc_cap.rf_params_mrdc.supported_band_combination_list_v1540.reset(band_combination_list_v1450);

  feature_set_combination_l feature_set_combination;

  feature_sets_per_band_l feature_sets_per_band;

  feature_set_c feature_set_eutra;
  feature_set_eutra.set_eutra();
  feature_set_eutra.eutra().dl_set_eutra = 1;
  feature_set_eutra.eutra().ul_set_eutra = 1;
  feature_sets_per_band.push_back(feature_set_eutra);

  feature_set_combination.push_back(feature_sets_per_band);

  feature_set_c feature_set_nr;
  feature_set_nr.set_nr();
  feature_set_nr.nr().dl_set_nr = 1;
  feature_set_nr.nr().ul_set_nr = 1;
  feature_sets_per_band.push_back(feature_set_nr);

  feature_set_combination.push_back(feature_sets_per_band);

  mrdc_cap.feature_set_combinations.push_back(feature_set_combination);

  // Pack mrdc_cap
  srsran::byte_buffer buffer;
  asn1::bit_ref       bref(buffer);
  mrdc_cap.pack(bref);

  ASSERT_EQ(test_pack_unpack_consistency(mrdc_cap), SRSASN_SUCCESS);

  //  srslog::fetch_basic_logger("RRC").info(
  //      buffer, bref.distance_bytes(), "Packed cap struct ({} bytes):", bref.distance_bytes());
}

TEST_F(asn1_rrc_nr_test, when_ue_mrdc_capabilities_correct_then_unpacking_successful)
{
  srsran::byte_buffer pdu =
      srsran::byte_buffer::create({0x01, 0x1c, 0x04, 0x81, 0x60, 0x00, 0x1c, 0x4d, 0x00, 0x00, 0x00, 0x04,
                                   0x00, 0x40, 0x04, 0x04, 0xd0, 0x10, 0x74, 0x06, 0x14, 0xe8, 0x1b, 0x10,
                                   0x78, 0x00, 0x00, 0x20, 0x00, 0x10, 0x08, 0x08, 0x01, 0x00, 0x20})
          .value();
  // 011c048160001c4d0000000400400404d010740614e81b107800002000100808010020

  asn1::cbit_ref bref{pdu};
  ue_mrdc_cap_s  mrdc_cap;

  ASSERT_EQ(mrdc_cap.unpack(bref), SRSASN_SUCCESS);

  ASSERT_EQ(test_pack_unpack_consistency(mrdc_cap), SRSASN_SUCCESS);
}

TEST_F(asn1_rrc_nr_test, when_ue_rrc_reconfiguration_correct_then_unpacking_successful)
{
  uint8_t             rrc_msg[] = "\x08\x81\x7c\x5c\x40\xb1\xc0\x7d\x48\x3a\x04\xc0\x3e\x01\x04\x54"
                                  "\x1e\xb5\x00\x02\xe8\x53\x98\xdf\x46\x93\x4b\x80\x04\xd2\x69\x34"
                                  "\x00\x00\x08\xc9\x8d\x6d\x8c\xa2\x01\xff\x00\x00\x00\x00\x01\x1b"
                                  "\x82\x21\x00\x00\x04\x04\x00\xd1\x14\x0e\x70\x00\x00\x08\xc9\xc6"
                                  "\xb6\xc6\x44\xa0\x00\x1e\xb8\x95\x63\xe0\x24\x94\x22\x0d\xb8\x44"
                                  "\x70\x0c\x02\x10\xb0\x1d\x80\x48\xf1\x18\x06\xea\x00\x08\x0e\x01"
                                  "\x25\xc0\xc8\x80\x37\x08\x42\x00\x00\x88\x16\x50\x02\x0c\x82\x00"
                                  "\x00\x20\x69\x81\x01\x45\x0a\x00\x0e\x48\x18\x00\x01\x33\x55\x64"
                                  "\x84\x1c\x00\x10\x40\xc2\x05\x0c\x1c\x9c\x40\x91\x42\xc6\x0d\x1c"
                                  "\x3c\x8e\x00\x00\x32\x21\x40\x30\x20\x01\x91\x4a\x01\x82\x00\x0c"
                                  "\x8c\x50\x0c\x18\x00\x64\x42\x80\xe1\x00\x03\x22\x94\x07\x0a\x00"
                                  "\x19\x18\xa0\x38\x60\x00\xc8\x85\x02\xc3\x80\x06\x45\x28\x16\x20"
                                  "\x64\x00\x41\x6c\x48\x04\x62\x82\x18\xa0\x08\xc5\x04\xb1\x60\x11"
                                  "\x8a\x0a\x63\x00\x23\x14\x16\xc6\x80\x46\x28\x31\x8e\x00\x8c\x50"
                                  "\x6b\x1e\x01\x18\xa0\xe6\x40\x00\x32\x31\x40\xb2\x23\x10\x0a\x08"
                                  "\x40\x90\x86\x05\x10\x43\xcc\x3b\x2a\x6e\x4d\x01\xa4\x92\x1e\x2e"
                                  "\xe0\x0c\x10\xe0\x00\x00\x01\x8f\xfd\x29\x49\x8c\x63\x72\x81\x60"
                                  "\x00\x02\x19\x70\x00\x00\x00\x00\x00\x00\x52\xf0\x0f\xa0\x84\x8a"
                                  "\xd5\x45\x00\x47\x00\x18\x00\x08\x20\x00\xe2\x10\x02\x40\x80\x70"
                                  "\x10\x10\x84\x00\x0e\x21\x00\x1c\xb0\x0e\x04\x02\x20\x80\x01\xc4"
                                  "\x20\x03\x96\x01\xc0\xc0\x42\x10\x00\x38\x84\x00\x73\x00\x38\x20"
                                  "\x08\x82\x00\x07\x10\x80\x0e\x60\x00\x40\x00\x00\x04\x10\xc0\x40"
                                  "\x80\xc1\x00\xe0\xd0\x00\x0e\x48\x10\x00\x00\x02\x00\x40\x00\x80"
                                  "\x60\x00\x80\x90\x02\x20\x0a\x40\x00\x02\x38\x90\x11\x31\xc8";
  srsran::byte_buffer pdu       = srsran::byte_buffer::create(rrc_msg).value();

  cbit_ref    bref(pdu);
  rrc_recfg_s rrc_recfg;

  ASSERT_EQ(rrc_recfg.unpack(bref), SRSASN_SUCCESS);
  ASSERT_EQ(rrc_recfg.rrc_transaction_id, 0);

#if JSON_OUTPUT
  json_writer jw;
  rrc_recfg.to_json(jw);
  test_logger.info("RRC Reconfig: \n {}", jw.to_string().c_str());
#endif

  ASSERT_EQ(rrc_recfg.crit_exts.type(), asn1::rrc_nr::rrc_recfg_s::crit_exts_c_::types::rrc_recfg);
  ASSERT_TRUE(rrc_recfg.crit_exts.rrc_recfg().secondary_cell_group.size() > 0);

  cell_group_cfg_s cell_group_cfg;
  cbit_ref         bref0(rrc_recfg.crit_exts.rrc_recfg().secondary_cell_group);
  ASSERT_EQ(cell_group_cfg.unpack(bref0), SRSASN_SUCCESS);

#if JSON_OUTPUT
  json_writer jw1;
  cell_group_cfg.to_json(jw1);
  test_logger.info("RRC Secondary Cell Group: \n {}", jw1.to_string().c_str());
#endif
  ASSERT_EQ(cell_group_cfg.cell_group_id, 1);
  ASSERT_EQ(cell_group_cfg.rlc_bearer_to_add_mod_list.size(), 1);
  ASSERT_TRUE(cell_group_cfg.mac_cell_group_cfg_present);
  ASSERT_TRUE(cell_group_cfg.phys_cell_group_cfg_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg_present);
}

TEST_F(asn1_rrc_nr_test, when_radio_bearer_config_correct_then_unpacking_successful)
{
  uint8_t             rrc_msg[] = "\x14\x09\x28\x17\x87\xc0\x0c\x28";
  srsran::byte_buffer pdu       = srsran::byte_buffer::create(rrc_msg).value();

  cbit_ref           bref(pdu);
  radio_bearer_cfg_s radio_bearer_cfg;
  ASSERT_EQ(radio_bearer_cfg.unpack(bref), SRSASN_SUCCESS);

#if JSON_OUTPUT
  json_writer jw;
  radio_bearer_cfg.to_json(jw);
  test_logger.info("RRC Bearer CFG Message: \n {}", jw.to_string().c_str());
#endif
  ASSERT_EQ(radio_bearer_cfg.drb_to_add_mod_list.size(), 1);
  ASSERT_TRUE(radio_bearer_cfg.security_cfg_present);
  ASSERT_TRUE(radio_bearer_cfg.security_cfg.security_algorithm_cfg_present);
  ASSERT_TRUE(radio_bearer_cfg.security_cfg.key_to_use_present);
}

TEST_F(asn1_rrc_nr_test, when_cell_group_config_correct_then_unpacking_successful)
{
  uint8_t             cell_group_config_raw[] = "\x5c\x40\xb1\xc0\x33\xc8\x53\xe0\x12\x0f\x05\x38\x0f\x80\x41\x15"
                                                "\x07\xad\x40\x00\xba\x14\xe6\x37\xd1\xa4\xd3\xa0\x01\x34\x9a\x5f"
                                                "\xc0\x00\x00\x33\x63\x6c\x91\x28\x80\x7f\xc0\x00\x00\x00\x00\x46"
                                                "\xe0\x88\x40\x00\x01\x01\x00\x34\x45\x03\x9c\x00\x00\x00\x33\x71"
                                                "\xb6\x48\x90\x04\x00\x08\x2e\x25\x18\xf0\x02\x4a\x31\x06\xe2\x8d"
                                                "\xb8\x44\x70\x0c\x02\x10\x38\x1d\x80\x48\xf1\x18\x5e\xea\x00\x08"
                                                "\x0e\x01\x25\xc0\xca\x80\x01\x7f\x80\x00\x00\x00\x00\x83\x70\x88"
                                                "\x20\x00\x08\x81\x65\x00\x20\xc8\x20\x00\x02\x06\x98\x10\x14\x50"
                                                "\xa0\x00\xe4\x81\x80\x00\x13\x35\x56\x48\x41\xc0\x01\x04\x0c\x20"
                                                "\x50\xc1\xc9\xc4\x09\x14\x2c\x60\xd1\xc3\xc8\xe0\x00\x03\x32\x14"
                                                "\x03\x02\x00\x19\x94\xa0\x18\x20\x00\xcc\xc5\x00\xc1\x80\x06\x64"
                                                "\x28\x0e\x10\x00\x33\x29\x40\x70\xa0\x01\x99\x8a\x03\x86\x00\x0c"
                                                "\xc8\x50\x2c\x38\x00\x66\x52\x81\x62\x06\x60\x04\x16\xc4\x80\x46"
                                                "\x48\x21\x8a\x00\x8c\x90\x4b\x16\x01\x19\x20\xa6\x30\x02\x32\x41"
                                                "\x6c\x68\x04\x64\x83\x18\xe0\x08\xc9\x06\xb1\xe0\x11\x92\x0e\x64"
                                                "\x00\x03\x33\x14\x0b\x22\x32\x00\xa0\x84\x09\x08\x60\x51\x04\x34"
                                                "\x3b\x2a\x65\xcd\x01\xa4\x92\x1e\x2e\xe0\x0c\x10\xe0\x00\x00\x01"
                                                "\x8f\xfd\x29\x49\x8c\x63\x72\x81\x60\x00\x02\x19\x70\x00\x00\x00"
                                                "\x00\x00\x00\x62\xf0\x0f\xa0\x84\x8a\xd5\x45\x00\x47\x00\x18\x00"
                                                "\x08\x20\x00\xe2\x10\x02\x40\x80\x70\x10\x10\x84\x00\x0e\x21\x00"
                                                "\x1c\xb0\x0e\x04\x02\x20\x80\x01\xc4\x20\x03\x96\x01\xc0\xc0\x42"
                                                "\x10\x00\x38\x84\x00\x73\x00\x38\x20\x08\x82\x00\x07\x10\x80\x0e"
                                                "\x60\x00\x40\x00\x00\x04\x10\xc0\x40\x80\xc1\x00\xe0\xd0\x00\x0e"
                                                "\x48\x10\x00\x00\x02\x00\x40\x00\x80\x60\x00\x80\x90\x02\x20\x0a"
                                                "\x40\x00\x02\x38\x90\x11\x31\xc8";
  srsran::byte_buffer pdu                     = srsran::byte_buffer::create(cell_group_config_raw).value();

  cbit_ref         bref(pdu);
  cell_group_cfg_s cell_group_cfg;

  ASSERT_EQ(cell_group_cfg.unpack(bref), SRSASN_SUCCESS);

  ASSERT_EQ(test_pack_unpack_consistency(cell_group_cfg), SRSASN_SUCCESS);

  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.serv_cell_idx_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.sp_cell_cfg_ded_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.sp_cell_cfg_ded.init_dl_bwp_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.sp_cell_cfg_ded.first_active_dl_bwp_id_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.sp_cell_cfg_ded.ul_cfg_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.sp_cell_cfg_ded.pdcch_serving_cell_cfg_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.sp_cell_cfg_ded.pdsch_serving_cell_cfg_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.sp_cell_cfg_ded.csi_meas_cfg_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.recfg_with_sync_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.pci_present);
  ASSERT_EQ(cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.pci, 500);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.dl_cfg_common_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common_present);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp_present);
  ASSERT_TRUE(
      cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common_present);

  ASSERT_EQ(
      cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common.type(),
      asn1::setup_release_opts::setup);
  ASSERT_TRUE(cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common
                  .is_setup());

  asn1::rrc_nr::rach_cfg_common_s& rach_cfg_common =
      cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common.setup();

  ASSERT_EQ(rach_cfg_common.rach_cfg_generic.prach_cfg_idx, 16);
  ASSERT_EQ(rach_cfg_common.rach_cfg_generic.msg1_fdm, asn1::rrc_nr::rach_cfg_generic_s::msg1_fdm_opts::one);
  ASSERT_EQ(rach_cfg_common.rach_cfg_generic.zero_correlation_zone_cfg, 0);
  ASSERT_EQ(rach_cfg_common.rach_cfg_generic.preamb_rx_target_pwr, -110);
  ASSERT_EQ(rach_cfg_common.rach_cfg_generic.preamb_trans_max,
            asn1::rrc_nr::rach_cfg_generic_s::preamb_trans_max_opts::n7);
  ASSERT_EQ(rach_cfg_common.rach_cfg_generic.pwr_ramp_step, asn1::rrc_nr::rach_cfg_generic_s::pwr_ramp_step_opts::db4);
  ASSERT_EQ(rach_cfg_common.rach_cfg_generic.ra_resp_win, asn1::rrc_nr::rach_cfg_generic_s::ra_resp_win_opts::sl10);
  ASSERT_TRUE(rach_cfg_common.ssb_per_rach_occasion_and_cb_preambs_per_ssb_present);

#if JSON_OUTPUT
  asn1::json_writer json_writer;
  cell_group_cfg.to_json(json_writer);
  test_logger.info("RRC Secondary Cell Group: Content: {}\n", json_writer.to_string().c_str());
#endif
}

TEST_F(asn1_rrc_nr_test, when_ue_nr_capabilities_rel15_correct_then_unpacking_successful)
{
  // UE caps of a Simcom SIM8262E-M2 5G module with IEs and extensions up to Rel15.4
  srsran::byte_buffer pdu =
      srsran::byte_buffer::create(
          {0xe1, 0xa0, 0x53, 0x80, 0x57, 0x4f, 0x7a, 0x03, 0x16, 0x00, 0x03, 0x06, 0x40, 0x02, 0xc1, 0x00, 0x10,
           0x18, 0x09, 0x31, 0x70, 0x01, 0x9c, 0x3d, 0x09, 0x00, 0x31, 0x20, 0xd0, 0x09, 0x80, 0x40, 0x62, 0x30,
           0x01, 0x50, 0x6c, 0x4d, 0xd6, 0x08, 0xc2, 0x1a, 0x08, 0x10, 0x74, 0x82, 0x40, 0x51, 0x6c, 0xaa, 0x2a,
           0x12, 0x1c, 0xfa, 0x06, 0x7d, 0x81, 0x3e, 0x31, 0xcf, 0x98, 0x63, 0xca, 0x16, 0x07, 0x03, 0x87, 0x81,
           0x70, 0x01, 0xdf, 0x00, 0x1c, 0x00, 0x77, 0xc0, 0x01, 0x22, 0x00, 0x36, 0x50, 0x00, 0x05, 0x00, 0x00,
           0x00, 0x12, 0x83, 0xc4, 0xd0, 0x00, 0xc2, 0x68, 0x00, 0x00, 0x20, 0x2e, 0x10, 0x71, 0x34, 0x00, 0x00,
           0x08, 0x78, 0x00, 0xc8, 0x0a, 0x14, 0x29, 0xdb, 0x2d, 0x78, 0xf0, 0x21, 0x6c, 0xb5, 0xe3, 0x8f, 0x41,
           0x28, 0x03, 0xe0, 0x03, 0x01, 0x01, 0x40, 0x18, 0x0c, 0x02, 0x50, 0x06, 0x00, 0x06, 0x03, 0xe0, 0x20,
           0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x80, 0x00, 0x02, 0x00, 0x40, 0x00, 0x01, 0x80,
           0x20, 0x00, 0x01, 0x00, 0x46, 0x50, 0xd6, 0x52, 0xd6, 0x4c, 0xde, 0x54, 0xd6, 0x46, 0xd0, 0x08, 0x10,
           0x00, 0x00, 0x01, 0xb0, 0x00, 0x40, 0x00, 0x04, 0x06, 0xc0, 0x01, 0x00, 0x00, 0x20, 0x1b, 0x00, 0x00,
           0x94, 0xa2, 0x2a, 0x94, 0xc5, 0xd2, 0xa8, 0xa1, 0x20, 0x17, 0x80, 0x4a, 0x05, 0x02, 0x81, 0x40, 0xa0,
           0x00, 0x48, 0x42, 0x00, 0x00, 0x84, 0x14, 0x00, 0x80, 0x18, 0x02, 0x00, 0x50, 0x08, 0x00, 0xc1, 0x40,
           0x08, 0x00, 0x80, 0x30, 0x01, 0x00, 0xa0, 0x00, 0x00, 0x20, 0x10, 0x01, 0x81, 0x60, 0x50})
          .value();
  // e1a05380574f7a03160003064002c1001018093170019c3d09003120d0098040623001506c4dd608c21a0810748240516caa2a121cfa067d813e31cf9863ca16070387817001df001c0077c0012200365000050000001283c4d000c2680000202e1071340000087800c80a1429db2d78f0216cb5e38f412803e003010140180c025006000603e0200200000001000002008000020040000180200001004650d652d64cde54d646d00810000001b00040000406c0010000201b000094a22a94c5d2a8a12017804a05028140a0004842000084140080180200500800c140080080300100a00000201001816050

  asn1::cbit_ref            bref{pdu};
  asn1::rrc_nr::ue_nr_cap_s ue_nr_cap;

  ASSERT_EQ(ue_nr_cap.unpack(bref), SRSASN_SUCCESS);

  ASSERT_EQ(test_pack_unpack_consistency(ue_nr_cap), SRSASN_SUCCESS);

#if JSON_OUTPUT
  asn1::json_writer json_writer;
  ue_nr_cap.to_json(json_writer);
  test_logger.info("UE capabilities: {}\n", json_writer.to_string().c_str());
#endif
}

TEST_F(asn1_rrc_nr_test, when_ue_nr_capabilities_rel16_correct_then_unpacking_successful)
{
  // UE caps of a QC SM8450 Snapdragon 8 Gen 1 module with AS release set to 16 and also IE and fields up to Rel16
  srsran::byte_buffer pdu =
      srsran::byte_buffer::create(
          {0xe1, 0xa2, 0x53, 0x80, 0x57, 0x4f, 0x7a, 0x03, 0x56, 0x08, 0x03, 0x04, 0x40, 0x0b, 0x04, 0x00, 0x40, 0x60,
           0x24, 0xc5, 0xc0, 0x06, 0x70, 0xf4, 0x1c, 0x01, 0x89, 0x06, 0x80, 0x4c, 0x02, 0x03, 0x11, 0x80, 0x82, 0x83,
           0x61, 0x3e, 0xb0, 0x46, 0x10, 0xd0, 0x40, 0x83, 0xa4, 0x0a, 0x0a, 0x2d, 0x95, 0x45, 0x42, 0x43, 0x9f, 0x40,
           0xcf, 0xb0, 0x27, 0xc6, 0x39, 0xf3, 0x0c, 0x79, 0x42, 0xc0, 0xe0, 0x70, 0xf0, 0x4e, 0x00, 0x3b, 0xe0, 0x03,
           0x80, 0x0e, 0xf8, 0x01, 0x50, 0x6c, 0x4d, 0xd6, 0x08, 0xc2, 0x1a, 0x08, 0x10, 0x74, 0x81, 0x41, 0x45, 0xb2,
           0xa8, 0xa8, 0x48, 0x73, 0xe8, 0x19, 0xf6, 0x04, 0xf8, 0xc7, 0x3e, 0x61, 0x8f, 0x28, 0x58, 0x1c, 0x0e, 0x1e,
           0x05, 0xc0, 0x07, 0x7c, 0x00, 0x70, 0x01, 0xdf, 0x00, 0x03, 0x08, 0x06, 0xca, 0x00, 0x00, 0xa0, 0x00, 0x00,
           0x28, 0x36, 0x12, 0xeb, 0x04, 0x61, 0x0d, 0x04, 0x08, 0x3a, 0x40, 0xa0, 0xa2, 0xd9, 0x54, 0x54, 0x24, 0x39,
           0xf4, 0x0c, 0xfb, 0x02, 0x7c, 0x63, 0x9f, 0x30, 0xc7, 0x94, 0x2c, 0x0e, 0x07, 0x0f, 0x04, 0xe0, 0x03, 0xb0,
           0x00, 0x38, 0x00, 0xec, 0x00, 0x05, 0x07, 0xc1, 0xbd, 0x60, 0x8c, 0x21, 0xa0, 0x81, 0x07, 0x88, 0x14, 0x12,
           0x5b, 0x2a, 0x8a, 0x82, 0x87, 0x3e, 0x81, 0x9f, 0x18, 0xe7, 0xcc, 0x31, 0xe5, 0x0b, 0x03, 0x81, 0xc3, 0xc0,
           0x9f, 0xd0, 0x00, 0x00, 0x07, 0xf4, 0x00, 0x00, 0x00, 0xa0, 0xf8, 0x0f, 0xac, 0x11, 0x84, 0x34, 0x10, 0x20,
           0xf1, 0x02, 0x82, 0x4b, 0x65, 0x51, 0x50, 0x50, 0xe7, 0xd0, 0x33, 0xe3, 0x1c, 0xf9, 0x86, 0x3c, 0xa1, 0x60,
           0x70, 0x38, 0x78, 0x13, 0xf8, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x14, 0x1f, 0x01, 0xb5, 0x82, 0x30,
           0x86, 0x82, 0x04, 0x1e, 0x20, 0x50, 0x49, 0x6c, 0xaa, 0x2a, 0x0a, 0x1c, 0xfa, 0x06, 0x7c, 0x63, 0x9f, 0x30,
           0xc7, 0x94, 0x2c, 0x0e, 0x07, 0x0f, 0x02, 0x7f, 0xf0, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x00, 0x02, 0x83, 0xe0,
           0x16, 0xb0, 0x46, 0x10, 0xd0, 0x40, 0x83, 0xc4, 0x0a, 0x09, 0x2d, 0x95, 0x45, 0x41, 0x43, 0x9f, 0x40, 0xcf,
           0x8c, 0x73, 0xe6, 0x18, 0xf2, 0x85, 0x81, 0xc0, 0xe1, 0xe0, 0x4f, 0xfe, 0x00, 0x00, 0x03, 0xff, 0x80, 0x00,
           0x00, 0x50, 0x7c, 0x00, 0xd6, 0x08, 0xc2, 0x1a, 0x08, 0x10, 0x78, 0x81, 0x41, 0x25, 0xb2, 0xa8, 0xa8, 0x28,
           0x73, 0xe8, 0x19, 0xf1, 0x8e, 0x7c, 0xc3, 0x1e, 0x50, 0xb0, 0x38, 0x1c, 0x3c, 0x09, 0xff, 0xc0, 0x00, 0x00,
           0x7f, 0xf0, 0x00, 0x00, 0x0a, 0x0f, 0x82, 0x7a, 0xc1, 0x18, 0x43, 0x41, 0x02, 0x0f, 0x10, 0x28, 0x24, 0xb6,
           0x55, 0x15, 0x05, 0x0e, 0x7d, 0x03, 0x3e, 0x31, 0xcf, 0x98, 0x63, 0xca, 0x16, 0x07, 0x03, 0x87, 0x81, 0x3f,
           0x80, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x00, 0xf8, 0xc3, 0x82, 0x70, 0x38, 0x9a, 0x00, 0x00, 0x00, 0x11,
           0x07, 0x84, 0xe0, 0x01, 0x84, 0xd0, 0x00, 0x08, 0x23, 0x0e, 0x09, 0x40, 0xe2, 0x68, 0x00, 0x00, 0x20, 0xe2,
           0x0f, 0x09, 0x40, 0x03, 0x09, 0xa0, 0x00, 0x30, 0xeb, 0x0e, 0x06, 0xc0, 0xe2, 0x68, 0x00, 0x00, 0x40, 0x80,
           0x75, 0x07, 0x83, 0x60, 0x01, 0x84, 0xd0, 0x00, 0x28, 0x48, 0x3a, 0xc3, 0x80, 0x70, 0x38, 0x9a, 0x00, 0x00,
           0x18, 0x20, 0x1d, 0x41, 0xe0, 0x38, 0x00, 0x61, 0x34, 0x00, 0x0e, 0x12, 0x0e, 0xb0, 0xe0, 0x18, 0x0e, 0x26,
           0x80, 0x00, 0x08, 0x08, 0x07, 0x50, 0x78, 0x0c, 0x00, 0x18, 0x4d, 0x00, 0x04, 0x84, 0x83, 0xac, 0x38, 0x02,
           0x03, 0x89, 0xa0, 0x00, 0x02, 0x82, 0x01, 0xd4, 0x1e, 0x01, 0x00, 0x06, 0x13, 0x40, 0x01, 0x61, 0x20, 0xeb,
           0x0e, 0x00, 0x00, 0xe2, 0x68, 0x00, 0x00, 0x80, 0x80, 0xba, 0x83, 0xc0, 0x00, 0x00, 0xc2, 0x68, 0x00, 0x24,
           0x24, 0x2e, 0xa1, 0x60, 0x00, 0x0c, 0x01, 0x01, 0xc1, 0xb0, 0x00, 0x01, 0x81, 0x00, 0x54, 0x2c, 0x00, 0x01,
           0xc0, 0x20, 0x00, 0xc0, 0xd8, 0x00, 0x34, 0x20, 0x0a, 0x85, 0xc0, 0x00, 0x00, 0xc0, 0x10, 0x18, 0x1b, 0x00,
           0x07, 0x04, 0x01, 0x50, 0x70, 0x04, 0x07, 0x06, 0xc0, 0x00, 0x07, 0x84, 0x01, 0x50, 0x78, 0x04, 0x00, 0x18,
           0x1b, 0x00, 0x08, 0x04, 0x01, 0x50, 0x70, 0x00, 0x07, 0x06, 0xc0, 0x00, 0x07, 0x84, 0x01, 0x50, 0x78, 0x00,
           0x00, 0x18, 0x1b, 0x00, 0x08, 0x04, 0x01, 0x00, 0x38, 0x26, 0x00, 0x00, 0x45, 0x41, 0xc0, 0x10, 0x1c, 0x07,
           0x00, 0x00, 0x24, 0x10, 0x05, 0x41, 0xe0, 0x10, 0x00, 0x60, 0x1c, 0x00, 0x26, 0x10, 0x05, 0x41, 0xc0, 0x00,
           0x1c, 0x07, 0x00, 0x00, 0x28, 0x10, 0x05, 0x41, 0xe0, 0x00, 0x00, 0x60, 0x1c, 0x00, 0x2a, 0x10, 0x05, 0x42,
           0xc0, 0x00, 0x18, 0x02, 0x03, 0x80, 0xc0, 0x00, 0x05, 0x82, 0x01, 0xd4, 0x2c, 0x00, 0x01, 0xc0, 0x20, 0x00,
           0xc0, 0x30, 0x00, 0x5c, 0x20, 0x1d, 0x42, 0xe0, 0x00, 0x00, 0x60, 0x08, 0x0c, 0x03, 0x00, 0x06, 0x02, 0x01,
           0xd4, 0x1c, 0x00, 0x01, 0xc0, 0x20, 0x00, 0x03, 0x21, 0x00, 0xea, 0x0f, 0x00, 0x00, 0x03, 0x00, 0x40, 0x01,
           0xa0, 0x80, 0x70, 0x94, 0x80, 0xb4, 0x87, 0xe1, 0x4e, 0x85, 0xb1, 0xcf, 0x87, 0x0a, 0x74, 0xed, 0x8e, 0x7c,
           0x38, 0x53, 0xa1, 0x6c, 0x73, 0xe1, 0xc2, 0x9d, 0x3b, 0x63, 0x9f, 0x0e, 0x14, 0xe8, 0x5b, 0x1c, 0xf8, 0x70,
           0xa7, 0x4e, 0xd8, 0xe7, 0xc3, 0x85, 0x3a, 0x16, 0xc7, 0x3e, 0x1c, 0x29, 0xd3, 0xb6, 0x39, 0xf0, 0xe1, 0x4e,
           0x85, 0xb1, 0xcf, 0x87, 0x0a, 0x74, 0xed, 0x8e, 0x7c, 0x38, 0x53, 0xa1, 0x6c, 0x73, 0xe1, 0xc2, 0x9d, 0x3b,
           0x63, 0x9f, 0x0e, 0x14, 0xe8, 0x5b, 0x1c, 0xf8, 0x70, 0xa7, 0x4e, 0xd8, 0xe7, 0xc3, 0x89, 0x3a, 0x74, 0xed,
           0x8e, 0x7c, 0x38, 0x93, 0xa7, 0x4e, 0xd8, 0xe7, 0xc3, 0x89, 0x3a, 0x74, 0xed, 0x8e, 0x7c, 0x38, 0x53, 0xa7,
           0x6c, 0x73, 0xe1, 0xc2, 0x9d, 0x3b, 0x63, 0x9f, 0x0e, 0x14, 0xe9, 0xdb, 0x1c, 0xf8, 0x70, 0xa7, 0x4e, 0xd8,
           0xe7, 0xc3, 0x81, 0x3b, 0x63, 0x9f, 0x0e, 0x14, 0xe9, 0xdb, 0x1c, 0xf8, 0x70, 0xa7, 0x4e, 0xd8, 0xe7, 0xc3,
           0x85, 0x3a, 0x76, 0xc7, 0x3e, 0x1c, 0x29, 0xd3, 0xb6, 0x39, 0xf0, 0xe2, 0x4e, 0x9d, 0x3b, 0x63, 0x9f, 0x0e,
           0x24, 0xe9, 0xd3, 0xb6, 0x39, 0xf0, 0xe2, 0x4e, 0x9d, 0x3b, 0x63, 0x9f, 0x0e, 0x14, 0xe9, 0xdb, 0x1c, 0xf8,
           0x70, 0xa7, 0x4e, 0xd8, 0xe7, 0xc3, 0x15, 0x8f, 0x88, 0x42, 0x10, 0xc4, 0x31, 0x0c, 0x43, 0x10, 0xc4, 0x21,
           0x08, 0x42, 0x10, 0x84, 0x21, 0x08, 0x42, 0x10, 0x84, 0x20, 0xf4, 0x12, 0xa0, 0x3e, 0x00, 0x30, 0x00, 0x70,
           0x00, 0x00, 0x10, 0x14, 0x01, 0x80, 0xc0, 0x25, 0x00, 0x60, 0x00, 0x60, 0x3e, 0x05, 0x00, 0x20, 0x00, 0x00,
           0x00, 0x10, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x18, 0x02, 0x00, 0x00, 0x10, 0x01,
           0x00, 0x00, 0x0a, 0x00, 0x80, 0x00, 0x06, 0x00, 0x40, 0x00, 0x03, 0x80, 0x20, 0x00, 0x02, 0x00, 0x10, 0x00,
           0x01, 0x20, 0x08, 0x00, 0x00, 0xa0, 0x29, 0x94, 0xb7, 0x95, 0x35, 0x93, 0x35, 0x82, 0x95, 0x81, 0x95, 0x83,
           0x35, 0x82, 0xb5, 0x81, 0x35, 0x81, 0x15, 0x81, 0xb5, 0x80, 0xb4, 0x07, 0x04, 0x00, 0x00, 0x25, 0x94, 0x90,
           0x10, 0x00, 0x01, 0x96, 0x52, 0x40, 0x40, 0x00, 0x0a, 0x59, 0x49, 0x01, 0x00, 0x00, 0x39, 0x65, 0x24, 0x04,
           0x00, 0x01, 0x25, 0x94, 0x90, 0x10, 0x00, 0x05, 0x96, 0x52, 0x40, 0x40, 0x00, 0x1a, 0x59, 0x49, 0x01, 0x00,
           0x00, 0x79, 0x65, 0x24, 0x01, 0xf4, 0xaa, 0x2a, 0x94, 0xc5, 0x52, 0x68, 0xaa, 0x0b, 0x15, 0x40, 0xe2, 0xa8,
           0x34, 0x55, 0x02, 0x8a, 0xa0, 0x31, 0x41, 0xd0, 0xae, 0x02, 0xa8, 0x14, 0x0a, 0x07, 0x03, 0x81, 0xc0, 0xe0,
           0x70, 0x38, 0x1c, 0x0e, 0x00, 0x0e, 0x84, 0x21, 0x08, 0x42, 0x10, 0x01, 0x22, 0x01, 0xc4, 0x00, 0x00, 0x02,
           0x01, 0x00, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x20, 0x10, 0x00, 0x00, 0x08, 0x04, 0x00, 0x00, 0x02, 0x01,
           0x00, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x20, 0x10, 0x00, 0x00, 0x08, 0x00, 0x34, 0x10, 0x10, 0x02, 0x00,
           0x00, 0x40, 0x10, 0x01, 0x08, 0x08, 0x01, 0x00, 0x40, 0x20, 0x08, 0x00, 0x04, 0x04, 0x01, 0x80, 0x00, 0x10,
           0x04, 0x00, 0x42, 0x02, 0x00, 0xc0, 0x18, 0x08, 0x02, 0x00, 0x01, 0x01, 0x00, 0x80, 0x00, 0x04, 0x01, 0x00,
           0x10, 0x80, 0x80, 0x40, 0x08, 0x02, 0x00, 0x80, 0x00, 0x40, 0x40, 0x28, 0x00, 0x01, 0x00, 0x40, 0x04, 0x20,
           0x20, 0x14, 0x02, 0x80, 0x80, 0x20, 0x00, 0x10, 0x10, 0x0c, 0x00, 0x00, 0x40, 0x10, 0x01, 0x08, 0x08, 0x06,
           0x00, 0xc0, 0x20, 0x08, 0x00, 0x04, 0x04, 0x03, 0x80, 0x00, 0x10, 0x04, 0x00, 0x42, 0x02, 0x01, 0xc0, 0x20,
           0x08, 0x02, 0x00, 0x02, 0x05, 0x01, 0x00, 0x02, 0x02, 0x80, 0x04, 0x04, 0x00, 0x00, 0x50, 0x0e, 0x00, 0x20,
           0x28, 0x00, 0x40, 0x40, 0x00, 0x05, 0x01, 0x20, 0x1e, 0x01, 0x40, 0x2c, 0x02, 0x00, 0x41, 0x02, 0x80, 0x80,
           0x01, 0x01, 0x40, 0x02, 0x02, 0x00, 0x00, 0x28, 0x07, 0x00, 0x90, 0x14, 0x01, 0x60, 0x20, 0x03, 0x82, 0x80,
           0x90, 0x01, 0x00, 0xa0, 0x02, 0x01, 0x00, 0x00, 0x81, 0x40, 0x40, 0x07, 0x80, 0xa0, 0x0b, 0x01, 0x00, 0x1c,
           0x14, 0x03, 0x80, 0x08, 0x0a, 0x00, 0x10, 0x10, 0x00, 0x01, 0x40, 0x48, 0x00, 0x80, 0x50, 0x01, 0x00, 0x80,
           0x00, 0x20, 0x20, 0x1c, 0x00, 0x00, 0x80, 0x40, 0x08, 0x10, 0x10, 0x0e, 0x01, 0x00, 0x40, 0x20, 0x00, 0x00,
           0x08, 0x05, 0x00, 0xa1, 0x01, 0x00, 0xe0, 0x00, 0x04, 0x02, 0x80, 0x50, 0x80, 0x80, 0x70, 0x08, 0x02, 0x01,
           0x40, 0x00, 0x40, 0x40, 0x30, 0x00, 0x01, 0x00, 0xa0, 0x14, 0x20, 0x20, 0x18, 0x03, 0x00, 0x80, 0x50, 0x00,
           0x20, 0x10, 0x14, 0x00, 0x00, 0x40, 0x50, 0x00, 0x01, 0x01, 0x40, 0x14, 0x40, 0x20, 0x28, 0x00, 0x00, 0x80,
           0xa0, 0x0a, 0x02, 0x02, 0x80, 0x00, 0x80, 0x40, 0x50, 0x05, 0x01, 0x01, 0x40, 0x00, 0x04, 0x05, 0x00, 0x00,
           0x81, 0x80, 0x60, 0x01, 0x00, 0xe0, 0x00, 0x0c, 0x05, 0x80, 0x88, 0x07, 0x00, 0x81, 0x03, 0x00, 0xc0, 0x1a,
           0x01, 0xc0, 0x20, 0x18, 0x0b, 0x00, 0x10, 0x0e, 0x00, 0x00, 0xb1, 0x70, 0x14, 0x06, 0x01, 0x4a, 0x20, 0x20,
           0x06, 0x73, 0x00})
          .value();
  // e1a25380574f7a0356080304400b0400406024c5c00670f41c018906804c020311808283613eb04610d04083a40a0a2d954542439f40cfb027c639f30c7942c0e070f04e003be003800ef801506c4dd608c21a081074814145b2a8a84873e819f604f8c73e618f28581c0e1e05c0077c007001df00030806ca0000a00000283612eb04610d04083a40a0a2d954542439f40cfb027c639f30c7942c0e070f04e003b0003800ec000507c1bd608c21a081078814125b2a8a82873e819f18e7cc31e50b0381c3c09fd0000007f4000000a0f80fac1184341020f102824b65515050e7d033e31cf9863ca16070387813f8000000fe000000141f01b582308682041e2050496caa2a0a1cfa067c639f30c7942c0e070f027ff000001ffc00000283e016b04610d04083c40a092d954541439f40cf8c73e618f28581c0e1e04ffe000003ff800000507c00d608c21a081078814125b2a8a82873e819f18e7cc31e50b0381c3c09ffc000007ff000000a0f827ac1184341020f102824b65515050e7d033e31cf9863ca16070387813f8000000fe0000000f8c38270389a000000110784e00184d00008230e0940e268000020e20f09400309a00030eb0e06c0e26800004080750783600184d00028483ac38070389a000018201d41e038006134000e120eb0e0180e26800008080750780c00184d00048483ac38020389a000028201d41e0100061340016120eb0e0000e26800008080ba83c00000c2680024242ea160000c0101c1b000018100542c0001c02000c0d80034200a85c00000c010181b000704015070040706c00007840150780400181b000804015070000706c00007840150780000181b0008040100382600004541c0101c07000024100541e01000601c0026100541c0001c07000028100541e00000601c002a100542c00018020380c000058201d42c0001c02000c030005c201d42e0000060080c0300060201d41c0001c02000032100ea0f000003004001a080709480b487e14e85b1cf870a74ed8e7c3853a16c73e1c29d3b639f0e14e85b1cf870a74ed8e7c3853a16c73e1c29d3b639f0e14e85b1cf870a74ed8e7c3853a16c73e1c29d3b639f0e14e85b1cf870a74ed8e7c3893a74ed8e7c3893a74ed8e7c3893a74ed8e7c3853a76c73e1c29d3b639f0e14e9db1cf870a74ed8e7c3813b639f0e14e9db1cf870a74ed8e7c3853a76c73e1c29d3b639f0e24e9d3b639f0e24e9d3b639f0e24e9d3b639f0e14e9db1cf870a74ed8e7c3158f884210c4310c4310c42108421084210842108420f412a03e00300070000010140180c025006000603e050020000000100000200800002004000018020000100100000a0080000600400003802000020010000120080000a02994b79535933582958195833582b58135811581b580b40704000025949010000196524040000a594901000039652404000125949010000596524040001a594901000079652401f4aa2a94c55268aa0b1540e2a83455028aa03141d0ae02a8140a070381c0e070381c0e000e8421084210012201c40000020100000080400000201000000804000002010000008040000020100000080034101002000040100108080100402008000404018000100400420200c01808020001010080000401001080804008020080004040280001004004202014028080200010100c000040100108080600c02008000404038000100400420201c0200802000205010002028004040000500e002028004040000501201e01402c020041028080010140020200002807009014016020038280900100a0020100008140400780a00b01001c140380080a001010000140480080500100800020201c000080400810100e010040200000080500a10100e000040280508080700802014000404030000100a0142020180300805000201014000040500001014014402028000080a00a020280008040500501014000040500008180600100e0000c0580880700810300c01a01c020180b00100e0000b1701406014a2020067300

  asn1::cbit_ref            bref{pdu};
  asn1::rrc_nr::ue_nr_cap_s ue_nr_cap;

  ASSERT_EQ(ue_nr_cap.unpack(bref), SRSASN_SUCCESS);

  ASSERT_EQ(test_pack_unpack_consistency(ue_nr_cap), SRSASN_SUCCESS);

#if JSON_OUTPUT
  asn1::json_writer json_writer;
  ue_nr_cap.to_json(json_writer);
  test_logger.info("UE capabilities: {}\n", json_writer.to_string().c_str());
#endif
}

TEST_F(asn1_rrc_nr_test, when_ue_nr_capabilities_rel16_v2_correct_then_unpacking_successful)
{
  // UE caps of a SIMCOM X62 based module with AS release set to 16 and also IE and fields up to Rel16
  srsran::byte_buffer pdu =
      srsran::byte_buffer::create(
          {0xe1, 0xa2, 0x53, 0x80, 0x57, 0x4f, 0x7a, 0x3,  0x56, 0x0,  0x3,  0xc3, 0xa8, 0x0,  0xb0, 0x1e, 0x80, 0x0,
           0x13, 0x0,  0x43, 0x20, 0x10, 0x24, 0x18, 0xf4, 0x4,  0x7b, 0x0,  0x3c, 0x13, 0x26, 0x43, 0x9f, 0x22, 0xd7,
           0xa0, 0xab, 0xd8, 0x25, 0xe8, 0x19, 0xf6, 0x4,  0xf8, 0x1e, 0x3c, 0x47, 0x1e, 0x47, 0x9f, 0x63, 0xcf, 0xb0,
           0x24, 0xc8, 0xf7, 0xe8, 0x3b, 0xf6, 0xd,  0xfb, 0x4,  0x8d, 0x8d, 0x3e, 0xc8, 0x1f, 0x60, 0x93, 0xb0, 0x69,
           0xd8, 0x35, 0xec, 0x59, 0xf2, 0x40, 0x4,  0x6,  0x2,  0x4c, 0x5c, 0x0,  0x67, 0xf,  0x42, 0x40, 0xc,  0x48,
           0x34, 0x2,  0x60, 0x30, 0xc,  0x47, 0x6,  0xaa, 0xf,  0x80, 0x9a, 0xc1, 0x18, 0x43, 0x41, 0x2,  0xf,  0x10,
           0x5c, 0x4,  0x16, 0xca, 0xa2, 0xa0, 0x22, 0xd7, 0x8c, 0x73, 0xe6, 0x19, 0xf2, 0x85, 0x81, 0xc0, 0xe3, 0xe0,
           0x2,  0x50, 0x0,  0x0,  0x34, 0x80, 0xc0, 0x70, 0x40, 0x1,  0xa7, 0xf0, 0x0,  0x0,  0x1,  0xfc, 0x0,  0x0,
           0x0,  0x14, 0x8,  0x1,  0x0,  0x80, 0x0,  0xd,  0x2a, 0xf,  0x80, 0x1a, 0xc1, 0x18, 0x43, 0x41, 0x2,  0xf,
           0x10, 0x5c, 0x4,  0x16, 0xca, 0xa2, 0xa0, 0x22, 0xd7, 0x8c, 0x73, 0xe6, 0x19, 0xf2, 0x85, 0x81, 0xc0, 0xe3,
           0xe0, 0x2,  0x50, 0x0,  0x0,  0x34, 0x80, 0xc0, 0x70, 0x40, 0x1,  0xa7, 0xfe, 0x0,  0x0,  0x1,  0xff, 0x80,
           0x0,  0x0,  0x14, 0x8,  0x1,  0x0,  0x80, 0x0,  0xd,  0x2a, 0xf,  0x80, 0x5a, 0xc1, 0x18, 0x43, 0x41, 0x2,
           0xf,  0x10, 0x5c, 0x4,  0x16, 0xca, 0xa2, 0xa0, 0x22, 0xd7, 0x8c, 0x73, 0xe6, 0x19, 0xf2, 0x85, 0x81, 0xc0,
           0xe3, 0xe0, 0x2,  0x50, 0x0,  0x0,  0x34, 0x80, 0xc0, 0x70, 0x40, 0x1,  0xa7, 0xfe, 0x0,  0x0,  0x1,  0xff,
           0x80, 0x0,  0x0,  0x14, 0x8,  0x1,  0x0,  0x80, 0x0,  0xd,  0x2a, 0xf,  0x80, 0xfa, 0xc1, 0x18, 0x43, 0x41,
           0x2,  0xf,  0x10, 0x5c, 0x4,  0x16, 0xca, 0xa2, 0xa0, 0x22, 0xd7, 0x8c, 0x73, 0xe6, 0x19, 0xf2, 0x85, 0x81,
           0xc0, 0xe3, 0xe0, 0x2,  0x50, 0x0,  0x0,  0x34, 0x80, 0xc0, 0x70, 0x40, 0x1,  0xa7, 0xf0, 0x0,  0x0,  0x1,
           0xfc, 0x0,  0x0,  0x0,  0x14, 0x8,  0x1,  0x0,  0x80, 0x0,  0xd,  0x2a, 0xf,  0x82, 0x3a, 0xc1, 0x18, 0x43,
           0x41, 0x2,  0xf,  0x10, 0x5c, 0x4,  0x16, 0xca, 0xa2, 0xa0, 0x22, 0xd7, 0x8c, 0x73, 0xe6, 0x19, 0xf2, 0x85,
           0x81, 0xc0, 0xe3, 0xe0, 0x2,  0x50, 0x0,  0x0,  0x34, 0x80, 0xc0, 0x70, 0x40, 0x1,  0xa7, 0xe0, 0x0,  0x0,
           0x1,  0xf8, 0x0,  0x0,  0x0,  0x14, 0x8,  0x1,  0x0,  0x80, 0x0,  0xd,  0x2a, 0xf,  0x83, 0x7a, 0xc1, 0x18,
           0x43, 0x41, 0x2,  0xf,  0x10, 0x5c, 0x4,  0x16, 0xca, 0xa2, 0xa0, 0x22, 0xd7, 0x8c, 0x73, 0xe6, 0x19, 0xf2,
           0x85, 0x81, 0xc0, 0xe3, 0xe0, 0x2,  0x50, 0x0,  0x0,  0x34, 0x80, 0xc0, 0x70, 0x40, 0x1,  0xa7, 0xf4, 0x0,
           0x0,  0x1,  0xfd, 0x0,  0x0,  0x0,  0x14, 0x8,  0x1,  0x0,  0x80, 0x0,  0xd,  0x2a, 0x8d, 0x84, 0xfa, 0xc1,
           0x18, 0x43, 0x41, 0x2,  0xe,  0x90, 0x5c, 0x5,  0x16, 0xca, 0xa2, 0xa1, 0x22, 0xd7, 0xa0, 0xab, 0xd8, 0x25,
           0xe3, 0x1c, 0xf9, 0x86, 0x3c, 0xa1, 0x60, 0x70, 0x38, 0xf8, 0x2,  0x10, 0x0,  0x0,  0x30, 0x80, 0xc0, 0x70,
           0x40, 0xb,  0x80, 0xe,  0xf8, 0x0,  0xe0, 0x3,  0xbe, 0x0,  0xa,  0x4,  0x0,  0x80, 0x40, 0x0,  0x6,  0x9d,
           0x46, 0xc2, 0x8c, 0xd,  0x60, 0x8c, 0x21, 0xa0, 0x81, 0x7,  0x48, 0x2e, 0x2,  0x8b, 0x65, 0x51, 0x50, 0x91,
           0x6b, 0xd0, 0x55, 0xec, 0x12, 0xf1, 0x8e, 0x7c, 0xc3, 0x1e, 0x50, 0xb0, 0x38, 0x1c, 0x7c, 0x1,  0x8,  0x0,
           0x0,  0x18, 0x40, 0x60, 0x38, 0x20, 0x5,  0xc0, 0x7,  0x7c, 0x0,  0x70, 0x1,  0xdf, 0x0,  0x5,  0xa,  0x0,
           0x6c, 0xa0, 0x0,  0xa,  0x0,  0x0,  0x0,  0x40, 0x20, 0x0,  0x3,  0x4a, 0xa3, 0x62, 0x66, 0xb0, 0x46, 0x10,
           0xd0, 0x40, 0x83, 0xa4, 0x17, 0x1,  0x45, 0xb2, 0xa8, 0xa8, 0x48, 0xb5, 0xe8, 0x2a, 0xf6, 0x9,  0x78, 0xc7,
           0x3e, 0x61, 0x8f, 0x28, 0x58, 0x1c, 0xe,  0x3e, 0x0,  0x84, 0x0,  0x0,  0xc,  0x20, 0x30, 0x1c, 0x10, 0x2,
           0xe0, 0x3,  0xbe, 0x0,  0x38, 0x0,  0xef, 0x80, 0x2,  0x85, 0x0,  0x36, 0x50, 0x0,  0x5,  0x0,  0x0,  0x0,
           0x20, 0x10, 0x0,  0x1,  0xa5, 0x51, 0xb1, 0x37, 0x58, 0x23, 0x8,  0x68, 0x20, 0x41, 0xd2, 0xb,  0x80, 0xa2,
           0xd9, 0x54, 0x54, 0x24, 0x5a, 0xf4, 0x15, 0x7b, 0x4,  0xbc, 0x63, 0x9f, 0x30, 0xc7, 0x94, 0x2c, 0xe,  0x7,
           0x1f, 0x0,  0x42, 0x0,  0x0,  0x6,  0x10, 0x18, 0xe,  0x8,  0x1,  0x70, 0x1,  0xdf, 0x0,  0x1c, 0x0,  0x77,
           0xc0, 0x1,  0x42, 0x80, 0x1b, 0x28, 0x0,  0x2,  0x80, 0x0,  0x0,  0x10, 0x8,  0x0,  0x0,  0xd2, 0xa8, 0xd8,
           0x9d, 0xac, 0x11, 0x84, 0x34, 0x10, 0x20, 0xe9, 0x5,  0xc0, 0x51, 0x6c, 0xaa, 0x2a, 0x12, 0x2d, 0x7a, 0xa,
           0xbd, 0x82, 0x5e, 0x31, 0xcf, 0x98, 0x63, 0xca, 0x16, 0x7,  0x3,  0x8f, 0x80, 0x21, 0x0,  0x0,  0x3,  0x8,
           0xc,  0x7,  0x4,  0x0,  0xb8, 0x0,  0x7,  0x80, 0xe,  0x0,  0x1,  0xe0, 0x0,  0xa0, 0x40, 0x8,  0x4,  0x0,
           0x0,  0x69, 0x50, 0x7c, 0x1,  0xd6, 0x8,  0xc2, 0x1a, 0x8,  0x10, 0x78, 0x82, 0xe0, 0x20, 0xb6, 0x55, 0x15,
           0x1,  0x16, 0xbc, 0x63, 0x9f, 0x30, 0xcf, 0x94, 0x2c, 0xe,  0x7,  0x1f, 0x0,  0x12, 0x80, 0x0,  0x1,  0xa4,
           0x6,  0x3,  0x82, 0x0,  0xd,  0x3f, 0x80, 0x0,  0x0,  0xf,  0xe0, 0x0,  0x0,  0x0,  0xa0, 0x40, 0x8,  0x4,
           0x0,  0x0,  0x69, 0x50, 0x7c, 0xb,  0xd6, 0x8,  0xc2, 0x1a, 0x8,  0x10, 0x78, 0x82, 0xe0, 0x20, 0xb6, 0x55,
           0x15, 0x1,  0x16, 0xbc, 0x63, 0x9f, 0x30, 0xcf, 0x94, 0x2c, 0xe,  0x7,  0x1f, 0x0,  0x12, 0x80, 0x0,  0x1,
           0xa4, 0x6,  0x3,  0x82, 0x0,  0xd,  0x3f, 0x0,  0x0,  0x0,  0xf,  0xc0, 0x0,  0x0,  0x0,  0xa0, 0x40, 0x8,
           0x4,  0x0,  0x0,  0x69, 0x50, 0x7c, 0xd,  0xd6, 0x8,  0xc2, 0x1a, 0x8,  0x10, 0x78, 0x82, 0xe0, 0x20, 0xb6,
           0x55, 0x15, 0x1,  0x16, 0xbc, 0x63, 0x9f, 0x30, 0xcf, 0x94, 0x2c, 0xe,  0x7,  0x1f, 0x0,  0x12, 0x80, 0x0,
           0x1,  0xa4, 0x6,  0x3,  0x82, 0x0,  0xd,  0x3e, 0x0,  0x0,  0x0,  0xf,  0x80, 0x0,  0x0,  0x0,  0xa0, 0x40,
           0x8,  0x4,  0x0,  0x0,  0x69, 0x50, 0x2c, 0x1c, 0xd6, 0x8,  0xc2, 0x1a, 0x8,  0x10, 0x78, 0x82, 0xe0, 0x20,
           0xb6, 0x55, 0x15, 0x1,  0x16, 0xbc, 0x63, 0x9f, 0x30, 0xcf, 0x94, 0x2c, 0xe,  0x7,  0x1f, 0x0,  0x12, 0x80,
           0x0,  0x1,  0xa4, 0x6,  0x3,  0x82, 0x0,  0xd,  0x3e, 0x0,  0x0,  0x0,  0xe,  0x0,  0x0,  0x0,  0x0,  0xa0,
           0x40, 0x8,  0x4,  0x0,  0x0,  0x69, 0x54, 0x6c, 0x2f, 0xd6, 0x8,  0xc2, 0x1a, 0x8,  0x10, 0x74, 0x82, 0xe0,
           0x28, 0xb6, 0x55, 0x15, 0x9,  0x16, 0xbd, 0x5,  0x5e, 0xc1, 0x2f, 0x18, 0xe7, 0xcc, 0x31, 0xe5, 0xb,  0x3,
           0x81, 0xc7, 0xc0, 0x10, 0x80, 0x0,  0x1,  0x84, 0x6,  0x3,  0x82, 0x0,  0x9c, 0x0,  0x77, 0xc0, 0x7,  0x0,
           0x1d, 0x80, 0x0,  0x50, 0x20, 0x4,  0x2,  0x0,  0x0,  0x34, 0xa8, 0x3e, 0x20, 0xeb, 0x4,  0x61, 0xd,  0x4,
           0x8,  0x3c, 0x41, 0x70, 0x10, 0x5b, 0x2a, 0x8a, 0x80, 0x8b, 0x5e, 0x31, 0xcf, 0x98, 0x67, 0xca, 0x16, 0x7,
           0x3,  0x8f, 0x80, 0x9,  0x40, 0x0,  0x0,  0xd2, 0x3,  0x1,  0xc1, 0x0,  0x6,  0x9f, 0xf8, 0x0,  0x0,  0x7,
           0xfe, 0x0,  0x0,  0x0,  0x50, 0x60, 0x1,  0x82, 0x4,  0x2,  0x0,  0x0,  0x34, 0xa8, 0x3e, 0x23, 0x6b, 0x4,
           0x61, 0xd,  0x4,  0x8,  0x3c, 0x41, 0x70, 0x10, 0x5b, 0x2a, 0x8a, 0x80, 0x8b, 0x5e, 0x31, 0xcf, 0x98, 0x67,
           0xca, 0x16, 0x7,  0x3,  0x8f, 0x80, 0x9,  0x40, 0x0,  0x0,  0xd2, 0x3,  0x1,  0xc1, 0x0,  0x6,  0x9f, 0xc0,
           0x0,  0x0,  0x7,  0xf0, 0x0,  0x0,  0x0,  0x50, 0x20, 0x4,  0x2,  0x0,  0x0,  0x34, 0xa8, 0x3e, 0xc,  0x6b,
           0x4,  0x61, 0xd,  0x4,  0x8,  0x3c, 0x41, 0x70, 0x10, 0x5b, 0x2a, 0x8a, 0x80, 0x8b, 0x5e, 0x31, 0xcf, 0x98,
           0x67, 0xca, 0x16, 0x7,  0x3,  0x8f, 0x80, 0x9,  0x40, 0x0,  0x0,  0xd2, 0x3,  0x1,  0xc1, 0x0,  0x6,  0x9f,
           0xf8, 0x0,  0x0,  0x7,  0xfe, 0x0,  0x0,  0x0,  0x50, 0x20, 0x4,  0x2,  0x0,  0x0,  0x34, 0xa8, 0x3e, 0xe,
           0xeb, 0x4,  0x61, 0xd,  0x4,  0x8,  0x3c, 0x41, 0x70, 0x10, 0x5b, 0x2a, 0x8a, 0x80, 0x8b, 0x5e, 0x31, 0xcf,
           0x98, 0x67, 0xca, 0x16, 0x7,  0x3,  0x8f, 0x80, 0x9,  0x40, 0x0,  0x0,  0xd2, 0x3,  0x1,  0xc1, 0x0,  0x6,
           0x9f, 0x0,  0x0,  0x0,  0x7,  0xc0, 0x0,  0x0,  0x0,  0x50, 0x20, 0x4,  0x2,  0x0,  0x0,  0x34, 0xa8, 0x3e,
           0x3,  0x6b, 0x4,  0x61, 0xd,  0x4,  0x8,  0x3c, 0x41, 0x70, 0x10, 0x5b, 0x2a, 0x8a, 0x80, 0x8b, 0x5e, 0x31,
           0xcf, 0x98, 0x67, 0xca, 0x16, 0x7,  0x3,  0x8f, 0x80, 0x9,  0x40, 0x0,  0x0,  0xd2, 0x3,  0x1,  0xc1, 0x0,
           0x6,  0x9f, 0xf8, 0x0,  0x0,  0x7,  0xfe, 0x0,  0x0,  0x0,  0x50, 0x20, 0x4,  0x2,  0x0,  0x0,  0x34, 0xa8,
           0x3e, 0x6,  0x6b, 0x4,  0x61, 0xd,  0x4,  0x8,  0x3c, 0x41, 0x70, 0x10, 0x5b, 0x2a, 0x8a, 0x80, 0x8b, 0x5e,
           0x31, 0xcf, 0x98, 0x67, 0xca, 0x16, 0x7,  0x3,  0x8f, 0x80, 0x9,  0x40, 0x0,  0x0,  0xd2, 0x3,  0x1,  0xc1,
           0x0,  0x6,  0x9f, 0x0,  0x0,  0x0,  0x7,  0xc0, 0x0,  0x0,  0x0,  0x50, 0x20, 0x4,  0x2,  0x0,  0x0,  0x34,
           0xa8, 0x3e, 0x9,  0xeb, 0x4,  0x61, 0xd,  0x4,  0x8,  0x3c, 0x41, 0x70, 0x10, 0x5b, 0x2a, 0x8a, 0x80, 0x8b,
           0x5e, 0x31, 0xcf, 0x98, 0x67, 0xca, 0x16, 0x7,  0x3,  0x8f, 0x80, 0x9,  0x40, 0x0,  0x0,  0xd2, 0x3,  0x1,
           0xc1, 0x0,  0x6,  0x9f, 0xc0, 0x0,  0x0,  0x7,  0xf0, 0x0,  0x0,  0x0,  0x50, 0x20, 0x4,  0x2,  0x0,  0x0,
           0x34, 0xa8, 0x3e, 0xc,  0xeb, 0x4,  0x61, 0xd,  0x4,  0x8,  0x3c, 0x41, 0x70, 0x10, 0x5b, 0x2a, 0x8a, 0x80,
           0x8b, 0x5e, 0x31, 0xcf, 0x98, 0x67, 0xca, 0x16, 0x7,  0x3,  0x8f, 0x80, 0x9,  0x40, 0x0,  0x0,  0xd2, 0x3,
           0x1,  0xc1, 0x0,  0x6,  0x9f, 0xc0, 0x0,  0x0,  0x7,  0xf0, 0x0,  0x0,  0x0,  0x50, 0x20, 0x4,  0x2,  0x0,
           0x0,  0x34, 0xaa, 0x36, 0x12, 0xeb, 0x4,  0x61, 0xd,  0x4,  0x8,  0x3a, 0x41, 0x70, 0x14, 0x5b, 0x2a, 0x8a,
           0x84, 0x8b, 0x5e, 0x82, 0xaf, 0x60, 0x97, 0x8c, 0x73, 0xe6, 0x18, 0xf2, 0x85, 0x81, 0xc0, 0xe3, 0xe0, 0x8,
           0x40, 0x0,  0x0,  0xc2, 0x3,  0x1,  0xc1, 0x0,  0x4e, 0x0,  0x3b, 0x0,  0x3,  0x80, 0xe,  0xc0, 0x0,  0x28,
           0x10, 0x2,  0x1,  0x0,  0x0,  0x1a, 0x54, 0xb,  0x12, 0xb5, 0x82, 0x30, 0x86, 0x82, 0x4,  0x1e, 0x20, 0xb8,
           0x8,  0x2d, 0x95, 0x45, 0x40, 0x45, 0xaf, 0x18, 0xe7, 0xcc, 0x33, 0xe5, 0xb,  0x3,  0x81, 0xc7, 0xc0, 0x4,
           0xa0, 0x0,  0x0,  0x69, 0x1,  0x80, 0xe0, 0x80, 0x3,  0x4f, 0xe8, 0x0,  0x0,  0x3,  0x80, 0x0,  0x0,  0x0,
           0x28, 0x10, 0x2,  0x1,  0x0,  0x0,  0x1a, 0x54, 0xb,  0x12, 0xf5, 0x82, 0x30, 0x86, 0x82, 0x4,  0x1e, 0x20,
           0xb8, 0x8,  0x2d, 0x95, 0x45, 0x40, 0x45, 0xaf, 0x18, 0xe7, 0xcc, 0x33, 0xe5, 0xb,  0x3,  0x81, 0xc7, 0xc0,
           0x4,  0xa0, 0x0,  0x0,  0x69, 0x1,  0x80, 0xe0, 0x80, 0x3,  0x4f, 0x0,  0x0,  0x0,  0x3,  0x80, 0x0,  0x0,
           0x0,  0x28, 0x10, 0x2,  0x1,  0x0,  0x0,  0x1a, 0x0,  0x80, 0x1c, 0x4,  0x0,  0x0,  0x0,  0x0,  0x20, 0x2,
           0xb,  0x90, 0x0,  0x38, 0x4,  0x0,  0x0,  0x38, 0x2,  0x0,  0xf,  0x41, 0x22, 0x3,  0xe0, 0x7,  0x0,  0x40,
           0x1,  0x1,  0x40, 0x18, 0xc,  0x2,  0x50, 0x6,  0x0,  0x6,  0x3,  0xe0, 0x0,  0x2,  0x0,  0x0,  0x0,  0x0,
           0x60, 0x65, 0x0,  0x1,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x14, 0xe,  0x28, 0x4a, 0x2,  0xe0, 0x3,  0x80,
           0x0,  0x20, 0x4,  0xa0, 0x0,  0x48, 0x0,  0x0,  0x20, 0x0,  0x0,  0x0,  0x0,  0x0,  0x1,  0x0,  0x20, 0x4,
           0xb,  0x17, 0x1,  0x40, 0x60, 0x14, 0xa2, 0x2,  0x0,  0x66, 0x30})
          .value();
  // e1a25380574f7a03560003c3a800b01e800013004320102418f4047b003c1326439f22d7a0abd825e819f604f81e3c471e479f63cfb024c8f7e83bf60dfb048d8d3ec81f6093b069d835ec59f2400406024c5c00670f42400c48340260300c4706aa0f809ac1184341020f105c0416caa2a022d78c73e619f28581c0e3e0025000003480c0704001a7f0000001fc0000001408010080000d2a0f801ac1184341020f105c0416caa2a022d78c73e619f28581c0e3e0025000003480c0704001a7fe000001ff8000001408010080000d2a0f805ac1184341020f105c0416caa2a022d78c73e619f28581c0e3e0025000003480c0704001a7fe000001ff8000001408010080000d2a0f80fac1184341020f105c0416caa2a022d78c73e619f28581c0e3e0025000003480c0704001a7f0000001fc0000001408010080000d2a0f823ac1184341020f105c0416caa2a022d78c73e619f28581c0e3e0025000003480c0704001a7e0000001f80000001408010080000d2a0f837ac1184341020f105c0416caa2a022d78c73e619f28581c0e3e0025000003480c0704001a7f4000001fd0000001408010080000d2a8d84fac1184341020e905c0516caa2a122d7a0abd825e31cf9863ca1607038f8021000003080c070400b800ef800e003be000a0400804000069d46c28c0d608c21a08107482e028b655150916bd055ec12f18e7cc31e50b0381c7c01080000184060382005c0077c007001df00050a006ca0000a000000402000034aa36266b04610d04083a4170145b2a8a848b5e82af60978c73e618f28581c0e3e008400000c20301c1002e003be003800ef800285003650000500000020100001a551b137582308682041d20b80a2d95454245af4157b04bc639f30c7942c0e071f004200000610180e08017001df001c0077c00142801b28000280000010080000d2a8d89dac1184341020e905c0516caa2a122d7a0abd825e31cf9863ca1607038f8021000003080c070400b80007800e0001e000a0400804000069507c01d608c21a08107882e020b655150116bc639f30cf942c0e071f0012800001a4060382000d3f8000000fe0000000a0400804000069507c0bd608c21a08107882e020b655150116bc639f30cf942c0e071f0012800001a4060382000d3f0000000fc0000000a0400804000069507c0dd608c21a08107882e020b655150116bc639f30cf942c0e071f0012800001a4060382000d3e0000000f80000000a0400804000069502c1cd608c21a08107882e020b655150116bc639f30cf942c0e071f0012800001a4060382000d3e0000000e00000000a0400804000069546c2fd608c21a08107482e028b655150916bd055ec12f18e7cc31e50b0381c7c01080000184060382009c0077c007001d800050200402000034a83e20eb04610d04083c4170105b2a8a808b5e31cf9867ca1607038f8009400000d20301c100069ff8000007fe000000506001820402000034a83e236b04610d04083c4170105b2a8a808b5e31cf9867ca1607038f8009400000d20301c100069fc0000007f000000050200402000034a83e0c6b04610d04083c4170105b2a8a808b5e31cf9867ca1607038f8009400000d20301c100069ff8000007fe00000050200402000034a83e0eeb04610d04083c4170105b2a8a808b5e31cf9867ca1607038f8009400000d20301c100069f00000007c000000050200402000034a83e036b04610d04083c4170105b2a8a808b5e31cf9867ca1607038f8009400000d20301c100069ff8000007fe00000050200402000034a83e066b04610d04083c4170105b2a8a808b5e31cf9867ca1607038f8009400000d20301c100069f00000007c000000050200402000034a83e09eb04610d04083c4170105b2a8a808b5e31cf9867ca1607038f8009400000d20301c100069fc0000007f000000050200402000034a83e0ceb04610d04083c4170105b2a8a808b5e31cf9867ca1607038f8009400000d20301c100069fc0000007f000000050200402000034aa3612eb04610d04083a4170145b2a8a848b5e82af60978c73e618f28581c0e3e008400000c20301c1004e003b0003800ec0002810020100001a540b12b582308682041e20b8082d95454045af18e7cc33e50b0381c7c004a00000690180e080034fe8000003800000002810020100001a540b12f582308682041e20b8082d95454045af18e7cc33e50b0381c7c004a00000690180e080034f00000003800000002810020100001a00801c040000000020020b9000380400003802000f412203e0070040010140180c025006000603e000020000000060650001000000000000140e284a02e00380002004a000480000200000000000010020040b1701406014a202006630

  asn1::cbit_ref            bref{pdu};
  asn1::rrc_nr::ue_nr_cap_s ue_nr_cap;

  ASSERT_EQ(ue_nr_cap.unpack(bref), SRSASN_SUCCESS);

  ASSERT_EQ(test_pack_unpack_consistency(ue_nr_cap), SRSASN_SUCCESS);

#if JSON_OUTPUT
  asn1::json_writer json_writer;
  ue_nr_cap.to_json(json_writer);
  test_logger.info("UE capabilities: {}\n", json_writer.to_string().c_str());
#endif
}
